import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:ichinesereader/constants.dart';
import 'package:ichinesereader/pages/common/myWords.dart';
import 'package:ichinesereader/pages/teacher/myFavoriteBooks.dart';
import 'package:ichinesereader/routes/routePages.dart';
import 'package:ichinesereader/utils/log.dart';
import 'package:ichinesereader/widgets/layouts/appdrawerTeacher.dart';
import 'package:ichinesereader/widgets/layouts/customAppBar.dart';
import 'package:ichinesereader/widgets/sidebars/teacherSidebar.dart';
import '../../themes/appTheme.dart';
import '../../themes/pageStyles.dart';

class LessonPlansPage extends StatelessWidget {
  static const String routeName = '/teacher/lessonplans';

  @override
  Widget build(BuildContext context) {
    Log.debug('build LessonPlansPage');
    final isSmallScreen =
        MediaQuery.of(context).size.width < Constants.DefinedScreenSmallSize;
    final isBigScreen =
        MediaQuery.of(context).size.width > Constants.DefinedScreenBigSize;
    int _selectedSidebarItem = RoutePages.teacherPageItems
        .indexWhere((page) => page.route == Get.currentRoute);
    final PageStyles _pageStyles = PageStyles();

    return DefaultTabController(
        length: 2,
        child: Scaffold(
          appBar: isSmallScreen ? CustomAppBar(title: 'Lesson Plans'.tr) : null,
          drawer: isSmallScreen ? TeacherAppDrawer() : null,
          body: Container(
            padding: isSmallScreen
                ? EdgeInsets.symmetric(horizontal: 12.0)
                : EdgeInsets.only(right: 12.0),
            decoration: _pageStyles.pageBoxDecoration(),
            child: Row(
              children: [
                Visibility(
                    visible: !isSmallScreen,
                    child: TeacherSidebarX(
                      selectedIndex: _selectedSidebarItem,
                      isBigScreen: isBigScreen,
                    )),
                Expanded(
                  flex: 9,
                  child: Column(
                    children: [
                      Container(
                        margin: EdgeInsets.only(top: 33.0),
                        decoration: BoxDecoration(
                          color: Get.isDarkMode
                              ? AppTheme.colors.darkTheme2
                              : Colors.black.withOpacity(0.1),
                          borderRadius: BorderRadius.circular(3.0),
                        ),
                        child: Stack(
                          alignment: Alignment.center,
                          children: [
                            Container(
                              margin: EdgeInsets.symmetric(vertical: 12.0),
                              child: _pageStyles.buildTabBar([
                                'Lesson Plans',
                                'My Words',
                              ]),
                            ),
                          ],
                        ),
                      ),
                      Expanded(
                        child: TabBarView(
                          children: [
                            MyFavoriteReadingBookTeacherPage(),
                            MyKnowledgeWordsPage(
                              folderId: '',
                              level: '',
                              isMainFolder: true,
                            )
                          ],
                        ),
                      )
                    ],
                  ),
                ),
              ],
            ),
          ),
        ));
  }
}
